import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:im_base/public/global/global.dart';
import 'package:im_base/public/tim/components/chat/emoji/data.dart';
import 'package:im_base/public/tim/components/chat/input/logic.dart';

class EmojiWidget extends StatelessWidget {
  final String id;

  EmojiWidget(this.id);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: (Global.KEYBOARD_HEIGHT == 0) ? Global.KEYBOARD_HEIGHT : 280,
      child: GridView.builder(
        gridDelegate:
            SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 7),
        itemCount: emojiList.length,
        itemBuilder: (context, index) {
          return emojiItem(emojiList[index], id);
        },
      ),
    );
  }
}

Widget emojiItem(EmojiModel e, String id) {
  return InkWell(
    onTap: () {
      Get.find<InputLogic>(tag: id).addEmoji(e.name);
    },
    child: Container(
      width: 24,
      height: 24,
      padding: EdgeInsets.all(8),
      child: Image.asset(e.path),
    ),
  );
}
